<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ViewAction
 *
 * @author wuxiaofeng
 */
class ViewAction extends MenuAction{
    public function viewlist(){
		if(isset($_GET['caid']) && intval($_GET['caid'])){
			$category_id=$_GET['caid'];
			
                        $Category=M("Category");
			$Content = M("Content");
                        if(isset($_GET['page']) && intval($_GET['page'])){
                            $currentPage = intval($_GET['page']);
                        }else{
                            $currentPage = 1;
                        }
                        $pageListRows = 4;
                        $totalRows = $Content->where('category_id='.$category_id.' AND content_state=1')->count();
                        $totalpages = ceil($totalRows/$pageListRows);
			$infos122=$Category->where('category_id='.$category_id)->find();
                        $infos123=$Content->where('category_id='.$category_id.' AND content_state=1')->limit($pageListRows)->page($currentPage)->select();
                        $this->assign('page',$currentPage);
                        $this->assign('totalpages',$totalpages);
                        $this->assign('infos122',$infos122);
			$this->assign('infos123',$infos123);
			$this->display();
		}else{
			$this->redirect('Index/index', '',0,'');
		}
	}
         public function news(){
             if(isset($_GET['newsid']) && intval($_GET['newsid'])){
                 $content_id=$_GET['newsid'];
                 $Content=M("Content");
                 $Category=M("Category");
                 
                 
                 $continfo=$Content->where('content_id='.$content_id)->find();
		 $data['content_id'] = $continfo['content_id'];
		 $data['content_click_count'] = $continfo['content_click_count']+1;
		 $Content->data($data)->save();
                 
                 
                 $cateinfo=$Category->where('category_id='.$continfo['category_id'])->find();
                 
                 $this->assign('continfo',$continfo);
                 $this->assign('cateinfo',$cateinfo);
                 $this->display();
                 
             }else{
			$this->redirect('Index/index', '',0,'');
		}
         }
}

?>
